/**
 * Created by Administrator on 14-8-21.
 */
$(function(){
    $.ajaxSetup({cache:false});
    $("#allCrExpressBanksDialog").dialog({
        autoOpen: false,
        modal: true,
        resizable: false,
        title: '选择银行',
        width:850,
        height:350
    });

    $("#c_c_f_0").attr("checked","checked");
});

var ccfastSel = function(bankImgId,img){
    $(img).prop("class","cur");
    $("#"+bankImgId).attr("checked","checked");
};

var showAllFastBanks = function(type){
    $("#a_c_c_f_0").attr("checked","checked");
    if(type=="03"){
        $("#allCrExpressBanksDialog").dialog("open");
    }else if(type=="06"){
        $("#allCrExpressBanksDialog").dialog("open");
    }
};

var ccfastPaySubmit = function(type,formId){
    $("#"+formId).submit();
};
//---login---
var refreshAuthCode = function(){
    $("#authCode").val("");
    var timestamp = (new Date()).getTime();
    $("#authCodeImg").attr("src", ctx+"/captcha/default.jpeg?timestamp=" + timestamp);
};

function sendSms(obj){
    if(null == obj)return;
    var bankPhoneNo = $("#bankPhoneNo").val();
    var orderId = $("#orderId").val();
    if(bankPhoneNo == null){
        $.alert('银行预留手机号错误');
        return;
    }
    $("#verifyCodeTip").html('');
    $(obj).attr('disabled','disabled');
    $.post(ctx+"/sms/send.shtml", {bankPhoneNo: bankPhoneNo, orderId: orderId}, function(data, textStatus) {
        if("0" == data.err_code){
            var max = 60;
            $(obj).attr('disabled','disabled');
            $(obj).attr('count',max);
            $(obj).text('免费获取('+max+'s)');
            setTimeout('checkTimeRemain("'+obj.id+'")',1000);
        }else{
            $.alert(data.err_msg);
            $(obj).removeAttr('disabled');
        }
    },'json');
}
function checkTimeRemain(objId){
    var obj = document.getElementById(objId);
    var c = new Number($(obj).attr('count'));
    var next = c-1;
    if(c <= 0){
        $(obj).removeAttr('disabled');
        $(obj).text($(obj).attr('title'));
        return;
    }else{
        $(obj).attr('count',next);
        if(next!=0){
            $(obj).text('免费获取('+next+'s)');
        }else{
            $(obj).text('免费获取');
        }
        setTimeout('checkTimeRemain("'+objId+'")',1000);
    }
}
